package com.coocaa.aries.core.tool.random;


import com.coocaa.aries.core.tool.date.DateUtil;

import java.util.Random;

/**
 * @author bijiahao
 * @date : 2019/7/18.
 * @description
 */
public final class RandomUtil {


    private RandomUtil() {
    }

    public static String getRandomLongStr() {
        String str = DateUtil.getCurrentDateStr("yyyyMMddHHmmss") + getRandNo(6);
        return str;
    }

    /**
     * 获取 存放目录-随机生成的
     *
     * @return
     */
    public static String getRandomStoreDir() {
        StringBuilder dir = new StringBuilder();
        dir.append(DateUtil.getCurDateStr("yyyyMMdd"))
                .append("/")
                .append(getRandomLongStr());
        return dir.toString();
    }

    public static String getRandNo(int dit) {
        StringBuffer sb = new StringBuffer("");
        Random random = new Random();

        for (int i = 0; i < dit; ++i) {
            sb.append(random.nextInt(10));
        }

        return sb.toString();
    }

}
